package com.tanhua.server.controller;

import com.tanhua.domain.vo.RecommendQueryVo;
import com.tanhua.server.service.IMService;
import com.tanhua.server.service.TanhuaService;
import com.tanhua.server.service.TodayBestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("tanhua")
public class TodayBestController {

    @Autowired
    private TodayBestService todayBestService;
    @Autowired
    private IMService imService;
    @Autowired
    private TanhuaService tanhuaService;

    /**
     * 接口名称：今日佳人
     * 接口路径：GET/tanhua/todayBest
     * 需求描述: 查询缘分值最高的用户。
     * 查询的表：recommend_user
     */
    @GetMapping("todayBest")
    public ResponseEntity<Object> queryTodayBest(){
        return todayBestService.queryTodayBest();
    }

    /**
     * 接口名称：推荐朋友 (首页 推荐用户)
     * 接口路径：GET/tanhua/recommendation
     * 需求描述: 分页查询推荐用户
     * 查询的表：recommend_user
     */
    @GetMapping("recommendation")
    public ResponseEntity<Object> recommendation(RecommendQueryVo param){
        return todayBestService.queryRecommendation(param);
    }

    /**
     * 接口名称：佳人信息 (首页点击推荐用户，查看推荐用户详情)
     * 接口路径：GET/tanhua/:id/personalInfo
     */
    @GetMapping("{id}/personalInfo")
    public ResponseEntity<Object> queryPersonalInfo(@PathVariable("id") Long recommendUserId){
        return todayBestService.queryPersonalInfo(recommendUserId);
    }

    /**
     * 接口名称：查询陌生人问题
     * 接口路径：GET/tanhua/strangerQuestions
     */
    @GetMapping("/strangerQuestions")
    public ResponseEntity<Object> strangerQuestions(Long userId) {
        return todayBestService.strangerQuestions(userId);
    }


    /**
     * 接口名称：回复陌生人问题
     * 接口路径：POST/tanhua/strangerQuestions
     */
    @PostMapping("/strangerQuestions")
    public ResponseEntity<Object> replyQuestions(@RequestBody Map<String,Object> paramMap) {
        Integer userId = (Integer) paramMap.get("userId");
        String reply = (String) paramMap.get("reply");
        return imService.replyQuestions(userId,reply);
    }

    /**
     * 接口名称：搜附近
     * 接口路径：GET/tanhua/search
     */
    @GetMapping("search")
    public ResponseEntity<Object> searchNear(String gender,Long distance){
        return todayBestService.searchNear(gender,distance);
    }


    @GetMapping("cards")
    public ResponseEntity<Object> cards(){
        return tanhuaService.tanhuaRecommendation();
    }

    @GetMapping("{uid}/love")
    public ResponseEntity<Object> fanLove(@PathVariable("uid") Long UserId){
        return tanhuaService.fanLove(UserId);
    }


    @GetMapping("{uid}/unlove")
    public ResponseEntity<Object> fanUnLove(@PathVariable("uid") Long UserId){
        return tanhuaService.fanUnLove(UserId);
    }
}
